package bancosys.tec.security.impl.services.incluir;

import jmine.tec.services.annotations.Input;
import jmine.tec.services.annotations.ServiceImplementor;
import jmine.tec.services.api.ActionsEnum;
import jmine.tec.services.api.export.ReferenceMap;
import jmine.tec.services.export.impl.ExportUtils;
import jmine.tec.services.io.ServiceBean;
import bancosys.tec.security.impl.domain.ChineseWallCredential;

/**
 * Serviço para inclusão de {@link ChineseWallCredential}
 * 
 * @author rodrigok
 */
@ServiceImplementor(action = ActionsEnum.INCLUIR)
public class ChineseWallCredentialService extends AbstractCredentialService<ChineseWallCredential> {

    public static final String ENTITY_NAME = "Nome da Entidade";

    public static final String FULL_ACCESS = "Acesso Ilimitado";

    public static final String DESCRIPTION = "Descrição";

    private String entityName;

    private Boolean fullAccess;

    private String description;

    /**
     * {@inheritDoc}
     */
    @Override
    protected void fillCredential(ChineseWallCredential credential) {
        credential.setEntityName(this.entityName);
        credential.setFullAccess(this.fullAccess);
        credential.setDescription(this.description);
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public void fillServiceBean(ServiceBean bean, ReferenceMap referenceMap, ChineseWallCredential entity) {
        super.fillServiceBean(bean, referenceMap, entity);
        ExportUtils.put(bean, ENTITY_NAME, entity.getEntityName());
        ExportUtils.put(bean, FULL_ACCESS, entity.getFullAccess());
        ExportUtils.put(bean, DESCRIPTION, entity.getDescription());
    }

    /**
     * @param entityName Nome da entidade a qual sera atribuida a permissao de acesso.
     */
    @Input(fieldName = ENTITY_NAME)
    public void setEntityName(String entityName) {
        this.entityName = entityName;
    }

    /**
     * @param fullAccess Indica se possui acesso total ao sistema.
     */
    @Input(fieldName = FULL_ACCESS)
    public void setFullAccess(Boolean fullAccess) {
        this.fullAccess = fullAccess;
    }

    /**
     * @param description Descrição da credencial.
     */
    @Input(fieldName = DESCRIPTION, required = false)
    public void setDescription(String description) {
        this.description = description;
    }
}
